<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>
        .box {
            border: 1px solid;

        }

        @keyframes myfirst {
            0% {
              
            }


            50% {
                transform: translateX(300px);
            }


            100% {
                /* transform: translateX(-300px); */
            }
        }

        .move {
            animation: myfirst 5s;
        }

        .circle {
            display: inline-block;
            background: red;
            height: 10px;
            width: 10px;
            transition: all 1s;
        }
    </style>
</head>

<body>

    <div class="box">

        <span class="circle"></span>
        <button onclick="clickfn()">点击</button>
    </div>
</body>

</html>

<script>
    function clickfn() {
        var $circle = document.querySelector('.circle');
        $circle.className = 'circle move';
        setTimeout(()=> {
            $circle.className = 'circle';
        },2500);
    }
</script>